// 错误级别枚举
export enum ErrorLevel {
  DEBUG = 'DEBUG',
  INFO = 'INFO',
  WARNING = 'WARNING', 
  ERROR = 'ERROR',
  FATAL = 'CRITICAL'  // 注意：后端使用的是CRITICAL而不是FATAL
}

// 平台类型
export enum PlatformType {
  H5 = 'H5',
  App = 'App', 
  MpWeixin = 'MpWeixin',
  MP_ALIPAY = 'mp-alipay',
  MP_BAIDU = 'mp-baidu', 
  MP_TOUTIAO = 'mp-toutiao',
  MP_QQ = 'mp-qq'
}

// SDK配置接口
export interface SDKConfig {
  apiKey: string;
  baseURL: string;
  projectId?: string;
  userId?: string;
  platform?: 'App' | 'MpWeixin' | 'H5'; // 新增：手动指定平台类型
  enableAutoReport?: boolean;
  enableConsoleLog?: boolean;
  maxRetryCount?: number;
  retryDelay?: number;
  batchSize?: number;
  flushInterval?: number;
  enablePerformanceMonitor?: boolean;
  enableNetworkMonitor?: boolean;
  enableUserBehavior?: boolean;
  customFields?: Record<string, any>;
}

// 错误信息接口
export interface ErrorInfo {
  level: ErrorLevel;
  message: string;
  stack_trace?: string;
  user_agent?: string;
  ip_address?: string;
  url?: string;
  timestamp?: number;
  platform?: PlatformType;
  device_info?: DeviceInfo;
  user_behavior?: UserBehavior[];
  performance_data?: PerformanceData;
  custom_data?: Record<string, any>;
}

// 设备信息接口
export interface DeviceInfo {
  platform: string;
  system: string;
  version: string;
  model?: string;
  brand?: string;
  screenWidth?: number;
  screenHeight?: number;
  pixelRatio?: number;
  language?: string;
  networkType?: string;
}

// 用户行为接口
export interface UserBehavior {
  type: 'click' | 'navigate' | 'api' | 'error' | 'custom' | 'form' | 'input' | 'scroll' | 'page' | 'session' | 'visibility';
  timestamp: number;
  data: Record<string, any>;
}

// 性能数据接口
export interface PerformanceData {
  loadTime?: number;
  renderTime?: number;
  memoryUsage?: number;
  networkLatency?: number;
}

// 上报响应接口
export interface ReportResponse {
  success: boolean;
  message?: string;
  errorId?: string;
}